package com.soft.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.soft.common.annotation.Log;
import com.soft.common.core.controller.BaseController;
import com.soft.common.core.domain.AjaxResult;
import com.soft.common.enums.BusinessType;
import com.soft.manage.domain.FlowNode;
import com.soft.manage.service.IFlowNodeService;
import com.soft.common.utils.poi.ExcelUtil;
import com.soft.common.core.page.TableDataInfo;

/**
 * 流程管理Controller
 * 
 * @author mobin
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/manage/node")
public class FlowNodeController extends BaseController
{
    @Autowired
    private IFlowNodeService flowNodeService;

    /**
     * 查询流程管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:node:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlowNode flowNode)
    {
        startPage();
        List<FlowNode> list = flowNodeService.selectFlowNodeList(flowNode);
        return getDataTable(list);
    }

    /**
     * 导出流程管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:node:export')")
    @Log(title = "流程管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlowNode flowNode)
    {
        List<FlowNode> list = flowNodeService.selectFlowNodeList(flowNode);
        ExcelUtil<FlowNode> util = new ExcelUtil<FlowNode>(FlowNode.class);
        util.exportExcel(response, list, "流程管理数据");
    }

    /**
     * 获取流程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:node:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(flowNodeService.selectFlowNodeById(id));
    }

    /**
     * 新增流程管理
     */
    @PreAuthorize("@ss.hasPermi('manage:node:add')")
    @Log(title = "流程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowNode flowNode)
    {
        return toAjax(flowNodeService.insertFlowNode(flowNode));
    }

    /**
     * 修改流程管理
     */
    @PreAuthorize("@ss.hasPermi('manage:node:edit')")
    @Log(title = "流程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowNode flowNode)
    {
        return toAjax(flowNodeService.updateFlowNode(flowNode));
    }

    /**
     * 删除流程管理
     */
    @PreAuthorize("@ss.hasPermi('manage:node:remove')")
    @Log(title = "流程管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flowNodeService.deleteFlowNodeByIds(ids));
    }
}
